package com.heima.schedule.feign;

import com.heima.apis.schedule.ITaskClient;
import com.heima.model.schedule.dtos.Task;
import com.heima.schedule.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class TaskClient implements ITaskClient {

    @Autowired
    private TaskService taskService;

    @PostMapping("/api/v1/task/addtask")
    public void addTask(@RequestBody Task task) {
        taskService.saveTask(task);

    }


    @GetMapping("/api/v1/task/poll/{taskType}/{taskpriority}")
    public Task poll(@PathVariable("taskType") Integer taskType, @PathVariable("taskpriority") Integer priority){
        return taskService.poll(taskType,priority);
    }

}
